package com.ln.lnzw.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ln.lnzw.R;
import com.ln.lnzw.app.AppConstant;
import com.ln.lnzw.base.BaseActivity;
import com.ln.lnzw.bean.BanjianCountNetBean;
import com.ln.lnzw.net.HttpMethods;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by wuwei on 2018/5/2.
 * 办件记录
 * 暂无接口
 * 现在有了,但是就一个数字显示,其余的还没开发完by wlt 05/08
 */

public class OfficeRecordsActivity extends BaseActivity {
    /**
     * 总办件	wdsqAll
     * 补正件	wdsqBzcl
     * 未提交	wdsqWtj
     * 待审核	wdsqDsh
     * 正在办理	wdsqZzbl
     * 不予批准	wdsqBypz
     * 已批准	wdsqYpz
     */
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.rl_my_weitijioa)
    RelativeLayout rlMyWeitijioa;
    @BindView(R.id.rl_my_daishenhe)
    RelativeLayout rlMyDaishenhe;
    @BindView(R.id.rl_my_daishoufei)
    RelativeLayout rlMyDaishoufei;
    @BindView(R.id.rl_my_zhengzaibanli)
    RelativeLayout rlMyZhengzaibanli;
    @BindView(R.id.rl_my_buzhencailiao)
    RelativeLayout rlMyBuzhencailiao;
    @BindView(R.id.rl_my_buyupizhun)
    RelativeLayout rlMyBuyupizhun;
    @BindView(R.id.rl_my_wodetongji)
    RelativeLayout rlMyWodetongji;

    @BindView(R.id.tv_weitijiao_count)
    TextView tv_weitijiao_count;
    @BindView(R.id.tv_daishenhe_count)
    TextView tv_daishenhe_count;
    @BindView(R.id.tv_daishoufei_count)
    TextView tv_daishoufei_count;
    @BindView(R.id.tv_zhengzaibanli_count)
    TextView tv_zhengzaibanli_count;
    @BindView(R.id.tv_buzhengcailiao_count)
    TextView tv_buzhengcailiao_count;
    @BindView(R.id.tv_buyupizhun_count)
    TextView tv_buyupizhun_count;
    @BindView(R.id.tv_wodetongji_count)
    TextView tv_wodetongji_count;

    private Unbinder unbinder;
    private String userId ;
    private String token;

    private static final String TAG = "OfficeRecordsActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_office_records);
       unbinder =  ButterKnife.bind(this);
       initData();
    }

    private void initData(){
        userId = activity.spUtils.getString(AppConstant.USER_UID);
        token = activity.spUtils.getString(AppConstant.TOKEN);
        HttpMethods.getInstanceCenter().info.getUserBanjianCount(token,userId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<BanjianCountNetBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addDisposable(d);
                    }

                    @Override
                    public void onNext(BanjianCountNetBean banjianCountNetBean) {
                        if (null != banjianCountNetBean.getResult())
                            setNumber(banjianCountNetBean);
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "获取办件数量出错 "+e.toString() );
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void setNumber(BanjianCountNetBean item){
        tv_weitijiao_count.setText("("+item.getResult().getWdsqWtj()+")");
        tv_daishenhe_count.setText("("+item.getResult().getWdsqdsh()+")");
        tv_daishoufei_count.setText("("+item.getResult().getWdsqYpz()+")");
        tv_zhengzaibanli_count.setText("("+item.getResult().getWdsqzzbl()+")");
        tv_buzhengcailiao_count.setText("("+item.getResult().getWdsqBzcl()+")");
        tv_buyupizhun_count.setText("("+item.getResult().getWdsqbypz()+")");
        tv_wodetongji_count.setText("("+item.getResult().getWdsqAll()+")");

    }


    @OnClick({R.id.iv_back, R.id.rl_my_weitijioa, R.id.rl_my_daishenhe, R.id.rl_my_daishoufei, R.id.rl_my_zhengzaibanli, R.id.rl_my_buzhencailiao, R.id.rl_my_buyupizhun, R.id.rl_my_wodetongji})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.rl_my_weitijioa:
                break;
            case R.id.rl_my_daishenhe:
                break;
            case R.id.rl_my_daishoufei:
                break;
            case R.id.rl_my_zhengzaibanli:
                break;
            case R.id.rl_my_buzhencailiao:
                break;
            case R.id.rl_my_buyupizhun:
                break;
            case R.id.rl_my_wodetongji:
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
}
